<?php

    /**
    * The register assembles all external input
    *
    * The register holds info assembled from all possible input
    *
    * @version $Revision$ $Date$
    *
    * @author $Author$
    * @abstract Register holds input passed in
    * @package Control
    * @copyright Copyright (c) 2010, MyKnowledgeMap  
    * @see http://www.MyKnowledgemap.com
    */    	
 
     /**
    * The register assembles all external input
    *
    * The register holds info assembled from all possible input
     * 
     * Class: Register
     * 
     * @package Control
     * @subpackage enter sub
     */
class Request {
	/**
	 * Holds all the values
	 * @var array $register
	 */
	protected static $register;
	
	/** 
	 * Singleton pattern
	 * @var Register $instance
	 */
	protected static $instance;
	/**
     * Constructs the register
     */
	protected function __construct() {
	   self::$register = array();
	   self::$register = array_merge( $_POST, self::$register );
	   self::$register = array_merge( $_GET, self::$register );
	   self::$register = array_merge( $_SESSION, self::$register );
	}
	/**
	 * gets this property from the register
	 * @param $string
	 */
	public static function prop( $string ){
		if( !isset( $instance ) ){
			self::$instance = new Request();
		}
		if( isset( self::$register[ $string ] ) ){
			return self::$register[ $string ];
		}
		return self::get_ValFromUri( $string );
	}
	
	/**
	 * 
	 * Look for contentType being passed through uri
	 */
	public static function get_ValFromUri( $key ){
		$chunks = explode("/",uri_string());
		for($i=0;$i<count($chunks);$i=$i+2){
			if($chunks[$i]== $key){
				return $chunks[$i+1];
			}
		}
		return "";
	}
}

?>